package day6;



import org.junit.Test;

import java.util.*;

public class ConnectionDemo {
    @Test
    public void test1() {
        Student[] array = new Student[3];
        //泛型
        //有序可重复
        List<Student> list = new ArrayList<>();
        Student student1 = new Student(1, "zhangsan");
        Student student2 = new Student(2, "lisi");
        Student student3 = new Student(3, "wangwu");
        Student student4 = new Student(4, "zhaoliu");
        list.add(student1);
        list.add(student2);
        list.add(student3);
        list.add(student4);
        list.add(student1);
        for (Student student : list) {
            System.out.println(student);
        }

        //ArrayList<String> list1 = new ArrayList<>();
        List<String> list1 = new ArrayList<>();
        list1.add("Java");
        list1.add("UI");
        list1.add("H5");
        list1.add("H5");
        list1.add("aa");
        for (String str : list1) {
            System.out.println(str);
        }
        System.out.println("------------");
        //无序不重复
        //HashSet<String> set = new HashSet<>();
        Set<String> set = new HashSet<>();
        set.add("Java");
        set.add("UI");
        set.add("H5");
        set.add("H5");
        set.add("aa");
        for (String stri : set) {
            System.out.println(stri);
        }
    }



    @Test
    public void test45() {
        Map<String, String> map = new HashMap<>();
        map.put("cn", "中国");
        map.put("us", "美国");
        map.put("uk", "英国");
        String country = map.get("cn");
        System.out.println(country);

        System.out.println("-------------");
        Set<Map.Entry<String, String>> entrySet = map.entrySet();
        for (Map.Entry<String, String> entry : entrySet) {
            System.out.println(entry.getKey() + " : " + entry.getValue());
        }

        System.out.println("-------------");
        Set<String> keySet = map.keySet();
        for (String key : keySet) {
            System.out.println(key + " : " + map.get(key));
        }


    }



}
